package com.yjweb.webportal.entities;

/**
 * Created by windMan on 2018/5/30
 */
public class ApiResult<T> {

    private int code;
    private boolean success;
    private String message;
    private T data;

    public ApiResult(){

    }

    public ApiResult(boolean success,String message){
        this(200,success,message);
    }

    public ApiResult(int code,boolean success,String message){
        this(code,success,message,null);
    }

    public ApiResult(int code,boolean success,String message,T data){
        this.code=code;
        this.success=success;
        this.message=message;
        this.data=data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static ApiResult success(){
        return new ApiResult(200,true,null,null);
    }

    public static ApiResult body(Object data){
        return new ApiResult(200,true,null,data);
    }

    public static ApiResult fault(String message){
        return new ApiResult(200,false,message,null);
    }
}
